<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="#{webContext.skin0Culomns}"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="center">
        
        <h:form id="addUserForm">
            <p:breadCrumb>  
                <p:menuitem value="#{ml.tr('Home')}" url="#{webContext.baseUrl}" />  
                <p:menuitem value="#{ml.tr('User list')}" url="#{lm.ml('secure/user/list.xhtml')}" />  
                <p:menuitem value="#{ml.tr('Add user')}" url="#" />  
            </p:breadCrumb>
            
            <p:wizard id="wiz" 
                      widgetVar="wiz" 
                      nextLabel="#{ml.tr('Next')}" 
                      backLabel="#{ml.tr('back')}"
                      flowListener="#{secureUserAdd.onFlowProcess}" 
                      style="width: 600px;">
                <p:tab title="#{ml.tr('Assessable data')}" id="personal">

                    <p:panel header="#{ml.tr('Assessable data')}">
                        <p:messages  />
                        <h:panelGrid columns="3" columnClasses="label, value" styleClass="grid">

                            <h:outputText value="#{ml.tr('Name')}: *" />
                            <p:inputText required="true" label="#{ml.tr('Name')}"
                                         value="#{secureUserAdd.user.firstname}"
                                         requiredMessage="#{ml.tr('The name is required')}"/>
                            <h:outputText />

                            <h:outputText value="#{ml.tr('Surname')} *" />
                            <p:inputText required="true" label="#{ml.tr('Surname')}"
                                         value="#{secureUserAdd.user.lastname}"
                                         requiredMessage="#{ml.tr('Surname is required.')}"/>
                            <h:outputText />

                            <h:outputText value="#{ml.tr('Username')}: *" />
                            <p:inputText required="true" label="#{ml.tr('Username')}"
                                         value="#{secureUserAdd.user.username}"
                                         requiredMessage="#{ml.tr('The username is required')}"/>
                            <h:outputText />
                            
                            <h:outputText value="#{ml.tr('Email')}: *" />
                            <p:inputText required="true" label="#{ml.tr('Email')}"
                                         value="#{secureUserAdd.user.email}"
                                         title="#{ml.tr('Email is username')}"
                                         requiredMessage="#{ml.tr('Email is required.')}">
                                <p:ajax event="blur" process="@this" update="emailMsg" />
                            </p:inputText>
                            <h:outputText id="emailMsg" styleClass="error"
                                          value="#{secureUserAdd.emailMsg}"/>

                            <h:outputText value="#{ml.tr('Email again')}: *" />
                            <p:inputText label="EmailStamp"
                                         value="#{secureUserAdd.emailStamp}" >
                                <p:ajax event="blur" update="emailStampMsg" />
                            </p:inputText>
                            <h:outputText id="emailStampMsg"
                                          value="#{secureUserAdd.emailStampMsg}"
                                          styleClass="error"/>

                            <h:outputText value="#{ml.tr('Password')}: *" />
                            <p:password id="password1" feedback="true" minLength="5"
                                        promptLabel="#{ml.tr('Please enter a password.')}"
                                        weakLabel="#{ml.tr('Weak password.')}"
                                        goodLabel="#{ml.tr('Good password.')}"
                                        strongLabel="#{ml.tr('Strong password.')}"
                                        value="#{secureUserAdd.user.passwd}"
                                        required="true"
                                        requiredMessage="#{ml.tr('Password is required.')}"
                                        validatorMessage="#{ml.tr('Password must contain min 5 symbols.')}">

                            </p:password>
                            <h:outputText />

                            <h:outputText value="#{ml.tr('Password again')}: *" />
                            <p:password feedback="false" minLength="5"
                                        value="#{secureUserAdd.passwordStamp}"
                                        inline="true" />
                            <h:outputText />
                        </h:panelGrid>
                    </p:panel>
                </p:tab>

                <p:tab title="#{ml.tr('Additional Info')}" id="additional">
                    <p:panel header="#{ml.tr('Additional Info')}">

                        <h:messages errorClass="error"/>

                        <h:panelGrid columns="2" columnClasses="label, value">
                            <h:outputText value="#{ml.tr('Street')}: " />
                            <p:inputText value="#{secureUserAdd.user.street}" />

                            <h:outputText value="#{ml.tr('ZIP')}: " />
                            <p:inputText value="#{secureUserAdd.user.postalCode}" />

                            <h:outputText value="#{ml.tr('City')}: " />
                            <p:inputText value="#{secureUserAdd.user.city}" />

                            <h:outputText value="#{ml.tr('Phone')}: " />
                            <p:inputText value="#{secureUserAdd.user.phone}"/>

                            <h:outputText value="#{ml.tr('Additional Info')}: " />
                            <p:inputText value="#{secureUserAdd.user.info}"/>
                        </h:panelGrid>
                    </p:panel>
                </p:tab>

                <p:tab title="#{ml.tr('Confirm')}" id="confirm">
                    <p:panel header="#{ml.tr('Confirm')}">

                        <p:growl id="growl" sticky="true" showDetail="true"/>

                        <h:panelGrid id="confirmation" columns="6">
                            <h:outputText value="#{ml.tr('Name')}: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{secureUserAdd.user.firstname}" />

                            <h:outputText value="#{ml.tr('Surname')}: " />
                            <h:outputText  styleClass="outputLabel"
                                           value="#{secureUserAdd.user.lastname}"/>
                            
                            <h:outputText value="#{ml.tr('Username')}: " />
                            <h:outputText  styleClass="outputLabel"
                                           value="#{secureUserAdd.user.username}"/>

                            <h:outputText value="#{ml.tr('Street')}: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{secureUserAdd.user.street}" />

                            <h:outputText value="#{ml.tr('ZIP')}: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{secureUserAdd.user.postalCode}" />

                            <h:outputText value="#{ml.tr('City')}: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{secureUserAdd.user.city}" />

                            <h:outputText value="#{ml.tr('Email')}: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{secureUserAdd.user.email}" />

                            <h:outputText value="#{ml.tr('Phone')}: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{secureUserAdd.user.phone}"/>

                            <h:outputText value="#{ml.tr('Additional Info')}: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{secureUserAdd.user.info}" />

                            <h:outputText />
                            <h:outputText />
                        </h:panelGrid>

                        <p:commandButton value="#{ml.tr('Save')}" update="growl"
                                         actionListener="#{secureUserAdd.save}">
                            <f:setPropertyActionListener value="password1"
                                                         target="#{secureUserAdd.user.passwd}" />
                        </p:commandButton>

                    </p:panel>
                </p:tab>
            </p:wizard>

            <p:ajaxStatus style="float: left">
                <f:facet name="start">
                    <h:graphicImage value="#{webContext.skinUrl}resources/ajaxloading.gif" />
                </f:facet>

                <f:facet name="complete">
                    <h:outputText value="" />
                </f:facet>
            </p:ajaxStatus>

        </h:form>
    </ui:define>

</ui:composition>
